package com.example.wacoffee_manage.Service.Impl;

import com.example.wacoffee_manage.Mapper.OrderMapper;
import com.example.wacoffee_manage.Mapper.PaymentMapper;
import com.example.wacoffee_manage.Service.paymentService;
import com.example.wacoffee_manage.pojo.Good;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public  class paymentServiceImpl implements paymentService {

    @Autowired
    private PaymentMapper paymentMapper;

    @Autowired
    private OrderMapper orderMapper;
    @Override
    public void pay(int orderId) {
        paymentMapper.pay(orderId);
    }
    @Override
    public void cancelPay(int orderId){
        List<Good> goods=orderMapper.getGoodsByOrderId(orderId);
        orderMapper.updateGoodStock(goods);
        paymentMapper.cancelPay(orderId);
    }
}
